<!DOCTYPE html>
<html>
<head><meta name="generator" content="Hexo 3.9.0">
  <meta charset="utf-8">
  
  <title>NDK Samples学习 [6-1] - camera之basic | 程序猜想</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="camera-basicREADME该项目演示如何使用c创建camera拍照、预览。  最低要求：  Android Studio 2.3.0+ ,NDK r15+ Android-24+   项目主要流程：  获取权限 初始化界面，NDKCamera、曝光度、感光度 操作相机，调整曝光度、感光度预览；拍照保存">
<meta name="keywords" content="ndk camera">
<meta property="og:type" content="article">
<meta property="og:title" content="NDK Samples学习 [6-1] - camera之basic">
<meta property="og:url" content="https://blog.520wa.com/2019/03/05/ndksamples-camera-basic/index.html">
<meta property="og:site_name" content="程序猜想">
<meta property="og:description" content="camera-basicREADME该项目演示如何使用c创建camera拍照、预览。  最低要求：  Android Studio 2.3.0+ ,NDK r15+ Android-24+   项目主要流程：  获取权限 初始化界面，NDKCamera、曝光度、感光度 操作相机，调整曝光度、感光度预览；拍照保存">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2019-11-21T12:51:12.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="NDK Samples学习 [6-1] - camera之basic">
<meta name="twitter:description" content="camera-basicREADME该项目演示如何使用c创建camera拍照、预览。  最低要求：  Android Studio 2.3.0+ ,NDK r15+ Android-24+   项目主要流程：  获取权限 初始化界面，NDKCamera、曝光度、感光度 操作相机，调整曝光度、感光度预览；拍照保存">
  
  
    <link rel="icon" href="/css/images/qrcode4assert1024.jpg">
  
  <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  <link rel="stylesheet" href="/css/style.css">
  

  <script>
  var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?e666d013b82854116bc37c32dd2f43e3";
  var s = document.getElementsByTagName("script")[0];
  s.parentNode.insertBefore(hm, s);
})();
(function(){
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
    }
    else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
  </script>
</head>
</html>
<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/" id="logo">程序猜想</a>
      </h1>
      
        <h2 id="subtitle-wrap">
          <a href="/" id="subtitle">写Java EE的Android程序员</a>
        </h2>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/">Home</a>
        
          <a class="main-nav-link" href="/archives">Archives</a>
        
          <a class="main-nav-link" href="/about">About</a>
        
      </nav>
      <nav id="sub-nav">
        
        <a id="nav-search-btn" class="nav-icon" title="Search"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="https://blog.520wa.com"></form>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main"><article id="post-ndksamples-camera-basic" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2019/03/05/ndksamples-camera-basic/" class="article-date">
  <time datetime="2019-03-05T09:40:44.000Z" itemprop="datePublished">2019-03-05</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/NDK-Samples/">NDK Samples</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      NDK Samples学习 [6-1] - camera之basic
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p><a href="https://github.com/googlesamples/android-ndk/tree/master/camera/basic/" target="_blank" rel="noopener">camera-basic</a><br><a href="https://github.com/googlesamples/android-ndk/blob/master/camera/README.md" target="_blank" rel="noopener">README</a><br>该项目演示如何使用c创建camera拍照、预览。</p>
<hr>
<p>最低要求：</p>
<ol>
<li>Android Studio 2.3.0+ ,NDK r15+</li>
<li>Android-24+</li>
</ol>
<hr>
<p>项目主要流程：</p>
<ol>
<li>获取权限</li>
<li>初始化界面，NDKCamera、曝光度、感光度</li>
<li>操作相机，调整曝光度、感光度预览；拍照保存</li>
</ol>
<a id="more"></a>
<hr>
<p>CameraActivity.java</p>
<ol>
<li>CameraSeekBar 包装SeekBar用于调整相机预览的曝光度、感光度</li>
</ol>
<p>void setImmersiveSticky() {} //设置全屏显示<br>public void RequestCamera() {} //请求权限，由c++调用<br>public void EnableUI(final long[] params){}//由c++调用，并传入曝光度、感光度参数<br>public void OnPhotoTaken(String fileName) {}//由c++调用，传入拍照图片路径<br>native static void notifyCameraPermission(boolean granted);//权限变化后<br>native static void TakePhoto();//调用c++拍照<br>native void OnExposureChanged(long exposure);//调用c++调整曝光度<br>native void OnSensitivityChanged(long sensitivity);//调用c++调整感光度<br>native static void notifyCameraPermission(boolean granted);//通知c++权限变化</p>
<p>android_main.cpp c主入口<br><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/*</span></span><br><span class="line"><span class="comment"> * SampleEngine global object</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">static</span> CameraEngine* pEngineObj = <span class="literal">nullptr</span>;</span><br><span class="line"><span class="comment">/*</span></span><br><span class="line"><span class="comment"> * 获取CameraEngine单例对象</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function">CameraEngine* <span class="title">GetAppEngine</span><span class="params">(<span class="keyword">void</span>)</span> </span>&#123;</span><br><span class="line">  ASSERT(pEngineObj, <span class="string">"AppEngine has not initialized"</span>);</span><br><span class="line">  <span class="keyword">return</span> pEngineObj;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 根据收到INIT_WINDOW/TERM_WINDOW事件创建或删除camera对象，</span></span><br><span class="line"><span class="comment"> * 使用NativeActivity的应用才会收到</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function"><span class="keyword">static</span> <span class="keyword">void</span> <span class="title">ProcessAndroidCmd</span><span class="params">(struct android_app* app, <span class="keyword">int32_t</span> cmd)</span> </span>&#123;</span><br><span class="line">  CameraEngine* engine = <span class="keyword">reinterpret_cast</span>&lt;CameraEngine*&gt;(app-&gt;userData);</span><br><span class="line">  <span class="keyword">switch</span> (cmd) &#123;</span><br><span class="line">    <span class="comment">// 窗口初始化</span></span><br><span class="line">    <span class="keyword">case</span> APP_CMD_INIT_WINDOW:</span><br><span class="line">      <span class="keyword">if</span> (engine-&gt;AndroidApp()-&gt;window != <span class="literal">NULL</span>) &#123;</span><br><span class="line">        engine-&gt;SaveNativeWinRes(ANativeWindow_getWidth(app-&gt;window),</span><br><span class="line">                                 ANativeWindow_getHeight(app-&gt;window),</span><br><span class="line">                                 ANativeWindow_getFormat(app-&gt;window));</span><br><span class="line">        <span class="comment">// 请求权限，创建camera</span></span><br><span class="line">        engine-&gt;OnAppInitWindow();</span><br><span class="line">      &#125;</span><br><span class="line">      <span class="keyword">break</span>;</span><br><span class="line">    <span class="comment">// 窗口关闭</span></span><br><span class="line">    <span class="keyword">case</span> APP_CMD_TERM_WINDOW:</span><br><span class="line">      <span class="comment">// 删除camera</span></span><br><span class="line">      engine-&gt;OnAppTermWindow();</span><br><span class="line">      ANativeWindow_setBuffersGeometry(</span><br><span class="line">          app-&gt;window, engine-&gt;GetSavedNativeWinWidth(),</span><br><span class="line">          engine-&gt;GetSavedNativeWinHeight(), engine-&gt;GetSavedNativeWinFormat());</span><br><span class="line">      <span class="keyword">break</span>;</span><br><span class="line">    <span class="comment">// 窗口配改变</span></span><br><span class="line">    <span class="keyword">case</span> APP_CMD_CONFIG_CHANGED:</span><br><span class="line">      engine-&gt;OnAppConfigChange();</span><br><span class="line">      <span class="keyword">break</span>;</span><br><span class="line">    <span class="comment">// 失去焦点</span></span><br><span class="line">    <span class="keyword">case</span> APP_CMD_LOST_FOCUS:</span><br><span class="line">      <span class="keyword">break</span>;</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">extern</span> <span class="string">"C"</span> <span class="function"><span class="keyword">void</span> <span class="title">android_main</span><span class="params">(struct android_app* state)</span> </span>&#123;</span><br><span class="line">  <span class="function">CameraEngine <span class="title">engine</span><span class="params">(state)</span></span>;</span><br><span class="line">  pEngineObj = &amp;engine;</span><br><span class="line"></span><br><span class="line">  state-&gt;userData = <span class="keyword">reinterpret_cast</span>&lt;<span class="keyword">void</span>*&gt;(&amp;engine);</span><br><span class="line">  state-&gt;onAppCmd = ProcessAndroidCmd;</span><br><span class="line"></span><br><span class="line">  <span class="comment">// loop waiting for stuff to do.</span></span><br><span class="line">  <span class="keyword">while</span> (<span class="number">1</span>) &#123;</span><br><span class="line">    <span class="comment">// Read all pending events.</span></span><br><span class="line">    <span class="keyword">int</span> events;</span><br><span class="line">    <span class="class"><span class="keyword">struct</span> <span class="title">android_poll_source</span>* <span class="title">source</span>;</span></span><br><span class="line"></span><br><span class="line">    <span class="keyword">while</span> (ALooper_pollAll(<span class="number">0</span>, <span class="literal">NULL</span>, &amp;events, (<span class="keyword">void</span>**)&amp;source) &gt;= <span class="number">0</span>) &#123;</span><br><span class="line">      <span class="comment">// Process this event.</span></span><br><span class="line">      <span class="keyword">if</span> (source != <span class="literal">NULL</span>) &#123;</span><br><span class="line">        source-&gt;process(state, source);</span><br><span class="line">      &#125;</span><br><span class="line"></span><br><span class="line">      <span class="comment">// Check if we are exiting.</span></span><br><span class="line">      <span class="keyword">if</span> (state-&gt;destroyRequested != <span class="number">0</span>) &#123;</span><br><span class="line">        LOGI(<span class="string">"CameraEngine thread destroy requested!"</span>);</span><br><span class="line">        engine.DeleteCamera();</span><br><span class="line">        pEngineObj = <span class="literal">nullptr</span>;</span><br><span class="line">        <span class="keyword">return</span>;</span><br><span class="line">      &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    pEngineObj-&gt;DrawFrame();</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 窗口初始化时调用，请求相机相关权限，并创建camera</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">void</span> CameraEngine::OnAppInitWindow(<span class="keyword">void</span>) &#123;</span><br><span class="line">  <span class="keyword">if</span> (!cameraGranted_) &#123;</span><br><span class="line">    <span class="comment">// 请求相机相关权限</span></span><br><span class="line">    RequestCameraPermission();</span><br><span class="line">    <span class="keyword">return</span>;</span><br><span class="line">  &#125;</span><br><span class="line"></span><br><span class="line">  <span class="comment">// 旋转角度</span></span><br><span class="line">  rotation_ = GetDisplayRotation();</span><br><span class="line"></span><br><span class="line">  <span class="comment">// 创建camera</span></span><br><span class="line">  CreateCamera();</span><br><span class="line">  ASSERT(camera_, <span class="string">"CameraCreation Failed"</span>);</span><br><span class="line"></span><br><span class="line">  <span class="comment">// 启用曝光度UI</span></span><br><span class="line">  EnableUI();</span><br><span class="line"></span><br><span class="line">  <span class="comment">// 预览</span></span><br><span class="line">  cameraReady_ = <span class="literal">true</span>;</span><br><span class="line">  camera_-&gt;StartPreview(<span class="literal">true</span>);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * Handle APP_CMD_TEMR_WINDOW</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">void</span> CameraEngine::OnAppTermWindow(<span class="keyword">void</span>) &#123;</span><br><span class="line">  cameraReady_ = <span class="literal">false</span>;</span><br><span class="line">  <span class="comment">// 销毁camera</span></span><br><span class="line">  DeleteCamera();</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * Handle APP_CMD_CONFIG_CHANGED</span></span><br><span class="line"><span class="comment"> * 获取旋转角度</span></span><br><span class="line"><span class="comment"> * 旋转角度有变化，销毁camera，再重新创建camera</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">void</span> CameraEngine::OnAppConfigChange(<span class="keyword">void</span>) &#123;</span><br><span class="line">  <span class="keyword">int</span> newRotation = GetDisplayRotation();</span><br><span class="line"></span><br><span class="line">  <span class="keyword">if</span> (newRotation != rotation_) &#123;</span><br><span class="line">    OnAppTermWindow();</span><br><span class="line"></span><br><span class="line">    rotation_ = newRotation;</span><br><span class="line">    OnAppInitWindow();</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<p>camera_engine.cpp<br><figure class="highlight xl"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 构造函数，初始camera资源</span></span><br><span class="line"><span class="comment"> * @param app native_app_glue environment</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line">CameraEngine::CameraEngine(android_app* app)</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 析构造函数，释放camera资源</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line">CameraEngine::~CameraEngine() &#123;</span><br><span class="line">  cameraReady_ = <span class="literal">false</span>;</span><br><span class="line">  DeleteCamera();</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 创建后台camera</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line">void CameraEngine::CreateCamera(void) &#123;</span><br><span class="line">  <span class="comment">// 没有权限直接返回</span></span><br><span class="line">  <span class="function"><span class="title">if</span> (!cameraGranted_ || !app_-&gt;</span>window) &#123;</span><br><span class="line">    LOGW(<span class="string">"Camera Sample requires Full Camera access"</span>);</span><br><span class="line">    return;</span><br><span class="line">  &#125;</span><br><span class="line"></span><br><span class="line">  int32_t displayRotation = GetDisplayRotation();</span><br><span class="line">  rotation_ = displayRotation;</span><br><span class="line"></span><br><span class="line">  <span class="comment">// 创建NDKCamera</span></span><br><span class="line">  camera_ = new NDKCamera();</span><br><span class="line">  ASSERT(camera_, <span class="string">"Failed to Create CameraObject"</span>);</span><br><span class="line"></span><br><span class="line">  <span class="comment">// 旋转角度</span></span><br><span class="line">  int32_t facing = <span class="number">0</span>, angle = <span class="number">0</span>, imageRotation = <span class="number">0</span>;</span><br><span class="line">  <span class="function"><span class="title">if</span> (camera_-&gt;</span>GetSensorOrientation(&amp;facing, &amp;angle)) &#123;</span><br><span class="line">    <span class="keyword">if</span> (facing == ACAMERA_LENS_FACING_FRONT) &#123;</span><br><span class="line">      imageRotation = (angle + rotation_) % <span class="number">360</span>;</span><br><span class="line">      imageRotation = (<span class="number">360</span> - imageRotation) % <span class="number">360</span>;</span><br><span class="line">    &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">      imageRotation = (angle - rotation_ + <span class="number">360</span>) % <span class="number">360</span>;</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;</span><br><span class="line">  LOGI(<span class="string">"Phone Rotation: %d, Present Rotation Angle: %d"</span>, rotation_,</span><br><span class="line">       imageRotation);</span><br><span class="line">  ImageFormat view&#123;<span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>&#125;, capture&#123;<span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>&#125;;</span><br><span class="line">  <span class="function"><span class="title">camera_</span>-&gt;</span>M<span class="function"><span class="title">atchCaptureSizeRequest</span>(app_-&gt;</span>window, &amp;view, &amp;capture);</span><br><span class="line"></span><br><span class="line">  ASSERT(view.width &amp;&amp; view.height, <span class="string">"Could not find supportable resolution"</span>);</span><br><span class="line"></span><br><span class="line">  <span class="comment">// Request the necessary nativeWindow to OS</span></span><br><span class="line">  bool portraitNativeWindow =</span><br><span class="line">      (savedNativeWinRes_.width &lt; savedNativeWinRes_.height);</span><br><span class="line">  ANativeWindow_setBuffersGeometry(</span><br><span class="line">      <span class="function"><span class="title">app_</span>-&gt;</span>window, portraitNativeWindow ? view.height : view.width,</span><br><span class="line">      portraitNativeWindow ? view.width : view.height, WINDOW_FORMAT_RGBA_8888);</span><br><span class="line"></span><br><span class="line">  yuvReader_ = new ImageReader(&amp;view, AIMAGE_FORMAT_YUV_420_888);</span><br><span class="line">  <span class="function"><span class="title">yuvReader_</span>-&gt;</span>SetPresentRotation(imageRotation);</span><br><span class="line">  jpgReader_ = new ImageReader(&amp;capture, AIMAGE_FORMAT_JPEG);</span><br><span class="line">  <span class="function"><span class="title">jpgReader_</span>-&gt;</span>SetPresentRotation(imageRotation);</span><br><span class="line">  <span class="function"><span class="title">jpgReader_</span>-&gt;</span>R<span class="function"><span class="title">egisterCallback</span>(this, [this](void* ctx, const char* str) -&gt;</span> void &#123;</span><br><span class="line">    <span class="function"><span class="title">reinterpret_cast</span>&lt;CameraEngine* &gt;(ctx)-&gt;</span>OnPhotoTaken(str);</span><br><span class="line">  &#125;);</span><br><span class="line"></span><br><span class="line">  <span class="comment">// now we could create session</span></span><br><span class="line">  <span class="function"><span class="title">camera_</span>-&gt;</span>C<span class="function"><span class="title">reateSession</span>(yuvReader_-&gt;</span>GetNativeWindow(),</span><br><span class="line">                         <span class="function"><span class="title">jpgReader_</span>-&gt;</span>GetNativeWindow(), imageRotation);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">// 释放camera</span></span><br><span class="line">void CameraEngine::DeleteCamera(void) &#123;</span><br><span class="line">  cameraReady_ = <span class="literal">false</span>;</span><br><span class="line">  <span class="keyword">if</span> (camera_) &#123;</span><br><span class="line">    delete camera_;</span><br><span class="line">    camera_ = nullptr;</span><br><span class="line">  &#125;</span><br><span class="line">  <span class="keyword">if</span> (yuvReader_) &#123;</span><br><span class="line">    delete yuvReader_;</span><br><span class="line">    yuvReader_ = nullptr;</span><br><span class="line">  &#125;</span><br><span class="line">  <span class="keyword">if</span> (jpgReader_) &#123;</span><br><span class="line">    delete jpgReader_;</span><br><span class="line">    jpgReader_ = nullptr;</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 请求camera相关权限</span></span><br><span class="line"><span class="comment"> *  通过调用CameraActivity.notifyCameraPermission,</span></span><br><span class="line"><span class="comment"> *  授权结果，调用native notifyCameraPermission()</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line">void CameraEngine::RequestCameraPermission() &#123;</span><br><span class="line">  <span class="keyword">if</span> (!app_) return;</span><br><span class="line"></span><br><span class="line">  JNIEnv* env;</span><br><span class="line">  AN<span class="function"><span class="title">ativeActivity</span>* activity = app_-&gt;</span>activity;</span><br><span class="line">  <span class="function"><span class="title">activity</span>-&gt;</span><span class="function"><span class="title">vm</span>-&gt;</span>GetEnv((void**)&amp;env, JNI_VERSION_1_6);</span><br><span class="line"></span><br><span class="line">  <span class="function"><span class="title">activity</span>-&gt;</span><span class="function"><span class="title">vm</span>-&gt;</span>AttachCurrentThread(&amp;env, NULL);</span><br><span class="line"></span><br><span class="line">  <span class="function"><span class="title">jobject</span> activityObj = env-&gt;</span>N<span class="function"><span class="title">ewGlobalRef</span>(activity-&gt;</span>clazz);</span><br><span class="line">  <span class="function"><span class="title">jclass</span> clz = env-&gt;</span>GetObjectClass(activityObj);</span><br><span class="line">  <span class="function"><span class="title">env</span>-&gt;</span>CallVoidMethod(activityObj,</span><br><span class="line">                      <span class="function"><span class="title">env</span>-&gt;</span>GetMethodID(clz, <span class="string">"RequestCamera"</span>, <span class="string">"()V"</span>));</span><br><span class="line">  <span class="function"><span class="title">env</span>-&gt;</span>DeleteGlobalRef(activityObj);</span><br><span class="line"></span><br><span class="line">  <span class="function"><span class="title">activity</span>-&gt;</span><span class="function"><span class="title">vm</span>-&gt;</span>DetachCurrentThread();</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 调整曝光度、感光度</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line">void CameraEngine::OnCameraParameterChanged(int32_t code, int64_t val) &#123;</span><br><span class="line">  <span class="function"><span class="title">camera_</span>-&gt;</span>UpdateCameraRequestParameter(code, val);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * The main function rendering a frame. In our case, it is yuv to RGBA8888</span></span><br><span class="line"><span class="comment"> * converter</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line">void CameraEngine::DrawFrame(void) &#123;</span><br><span class="line">  <span class="keyword">if</span> (!cameraReady_ || !yuvReader_) return;</span><br><span class="line">  AI<span class="function"><span class="title">mage</span>* image = yuvReader_-&gt;</span>GetNextImage();</span><br><span class="line">  <span class="keyword">if</span> (!image) &#123;</span><br><span class="line">    return;</span><br><span class="line">  &#125;</span><br><span class="line"></span><br><span class="line">  AN<span class="function"><span class="title">ativeWindow_acquire</span>(app_-&gt;</span>window);</span><br><span class="line">  ANativeWindow_Buffer buf;</span><br><span class="line">  <span class="function"><span class="title">if</span> (ANativeWindow_lock(app_-&gt;</span>window, &amp;buf, nullptr) &lt; <span class="number">0</span>) &#123;</span><br><span class="line">    <span class="function"><span class="title">yuvReader_</span>-&gt;</span>DeleteImage(image);</span><br><span class="line">    return;</span><br><span class="line">  &#125;</span><br><span class="line"></span><br><span class="line">  <span class="function"><span class="title">yuvReader_</span>-&gt;</span>DisplayImage(&amp;buf, image);</span><br><span class="line">  AN<span class="function"><span class="title">ativeWindow_unlockAndPost</span>(app_-&gt;</span>window);</span><br><span class="line">  AN<span class="function"><span class="title">ativeWindow_release</span>(app_-&gt;</span>window);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<p>camera_ui.cpp<br><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 获取旋转角度Retrieve current rotation from Java side</span></span><br><span class="line"><span class="comment"> * 调用CameraActivity.getRotationDegree</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">int</span> CameraEngine::GetDisplayRotation() &#123;</span><br><span class="line">  ...</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 设置曝光度、感光度</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">void</span> CameraEngine::EnableUI(<span class="keyword">void</span>) &#123;</span><br><span class="line">   <span class="comment">// 1. 获取曝光度，感光度NDKCamera::GetExposureRange\NDKCamera::GetSensitivityRange</span></span><br><span class="line">  <span class="comment">// 2. 调用CameraActivity.EnableUI设置</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 拍照</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">void</span> CameraEngine::OnTakePhoto() &#123;</span><br><span class="line">  <span class="keyword">if</span> (camera_) &#123;</span><br><span class="line">    camera_-&gt;TakePhoto();</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 回传照片文件路径，CameraActivity.OnPhotoTaken</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">void</span> CameraEngine::OnPhotoTaken(<span class="keyword">const</span> <span class="keyword">char</span>* fileName) &#123;</span><br><span class="line">  ...</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * camera和文件写入权限回调</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">void</span> CameraEngine::OnCameraPermission(jboolean granted) &#123;</span><br><span class="line">  <span class="comment">//有权限则调用OnAppInitWindow初始化</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> *  native响应权限变化</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">extern</span> <span class="string">"C"</span> JNIEXPORT <span class="keyword">void</span> JNICALL</span><br><span class="line">Java_com_sample_camera_basic_CameraActivity_notifyCameraPermission(</span><br><span class="line">    JNIEnv *env, jclass type, jboolean permission) &#123;</span><br><span class="line">  <span class="comment">//CameraEngine::OnCameraPermission权限变化</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> *  native拍照</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">extern</span> <span class="string">"C"</span> JNIEXPORT <span class="keyword">void</span> JNICALL</span><br><span class="line">Java_com_sample_camera_basic_CameraActivity_TakePhoto(JNIEnv *env,</span><br><span class="line">                                                      jclass type) &#123;</span><br><span class="line">  <span class="comment">//CameraEngine::OnTakePhoto</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> *  native曝光度变化，调整预览</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">extern</span> <span class="string">"C"</span> JNIEXPORT <span class="keyword">void</span> JNICALL</span><br><span class="line">Java_com_sample_camera_basic_CameraActivity_OnExposureChanged(</span><br><span class="line">    JNIEnv *env, jobject instance, jlong exposurePercent) &#123;</span><br><span class="line">  <span class="comment">//GetAppEngine()::OnCameraParameterChanged</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> *  native感光度变化，调整预览</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">extern</span> <span class="string">"C"</span> JNIEXPORT <span class="keyword">void</span> JNICALL</span><br><span class="line">Java_com_sample_camera_basic_CameraActivity_OnSensitivityChanged(</span><br><span class="line">    JNIEnv *env, jobject instance, jlong sensitivity) &#123;</span><br><span class="line">  <span class="comment">//GetAppEngine()::OnCameraParameterChanged</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<p>camera_manager.cpp   </p>
<ol>
<li>初始化camera</li>
<li>更新属性</li>
<li>拍照</li>
</ol>
<p>image_reader.cpp   图片转换相关<br>camera_listeners.cpp camera manager相关Listener</p>
<hr>
<p>项目功能为：</p>
<ol>
<li>native监听窗口变化判断调用java请求camera相关权限</li>
<li>native创建NDKCamera，并获取曝光度、感光度属性回调到Java并展示</li>
<li>native预览</li>
<li>java调用native调整预览曝光度、感光度</li>
<li>java调用native拍照并回调java提示图片文件路径</li>
</ol>
<hr>
<h3 id="android-ndk-samples学习目录"><a href="#android-ndk-samples学习目录" class="headerlink" title="android-ndk-samples学习目录"></a>android-ndk-samples学习目录</h3><p>部份引用其他大牛的项目</p>
<ol>
<li><p><a href="https://www.jianshu.com/p/a5a6c3fdb622" target="_blank" rel="noopener">hello-jni</a> by 七零八落问号<br>演示如何从Java层调用C层代码。</p>
</li>
<li><p><a href="https://www.jianshu.com/p/499826cb97fc" target="_blank" rel="noopener">hello-jniCallback</a> by 七零八落问<br>演示如何在C层回调Java层方法。</p>
</li>
<li><p><a href="https://www.jianshu.com/p/b3be6b2ee87c" target="_blank" rel="noopener">hello-libs</a> by 七零八落问<br>演示如何在Android Studio上使用第三方的C / C++库。</p>
</li>
<li><p><a href="https://blog.csdn.net/foolish0421/article/details/78018926" target="_blank" rel="noopener">audio echo</a> by hunter800421<br>演示如何如何使用OpenSL ES创建播放器和录音。</p>
</li>
<li><p><a href="https://blog.csdn.net/foolish0421/article/details/78123165" target="_blank" rel="noopener">bitmap-plasma</a> by hunter800421<br>演示如何使用c代码在bitmap上绘制细胞质效果。</p>
</li>
</ol>
<p>6.1.  <a href="http://blog.520wa.com/2019/03/05/ndksamples-camera-basic/">camera-basic</a> by  Tu<br>    演示如何使用c创建camera拍照、预览。</p>
<h5 id="参考"><a href="#参考" class="headerlink" title="参考"></a>参考</h5><p><a href="http://tieba.baidu.com/p/2650541001?traceid=" target="_blank" rel="noopener">NatvieActivity事件</a></p>
<h6 id="转载请标明出处："><a href="#转载请标明出处：" class="headerlink" title="转载请标明出处："></a>转载请标明出处：</h6><h6 id="http-2tu-github-io"><a href="#http-2tu-github-io" class="headerlink" title="http://2tu.github.io/"></a><a href="http://2tu.github.io/" target="_blank" rel="noopener">http://2tu.github.io/</a></h6><h6 id="本文出自Tu’s-blog"><a href="#本文出自Tu’s-blog" class="headerlink" title="本文出自Tu’s blog"></a>本文出自Tu’s blog</h6>
      
    </div>
    <footer class="article-footer">
      <a data-url="https://blog.520wa.com/2019/03/05/ndksamples-camera-basic/" data-id="ckcqflawc000teode1qc9yg66" class="article-share-link">Share</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/ndk-camera/">ndk camera</a></li></ul>

    </footer>
  </div>
  
    
<nav id="article-nav">
  
    <a href="/2019/04/23/assert-facepay-dragonfly-by-4/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Newer</strong>
      <div class="article-nav-title">
        
          人脸支付怎么敢采用后4位手机号
        
      </div>
    </a>
  
  
    <a href="/2019/02/14/cpp-constructor-rule/" id="article-nav-older" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Older</strong>
      <div class="article-nav-title">C++构造函数设计原理</div>
    </a>
  
</nav>

  
</article>

</section>
        
          <aside id="sidebar">
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Categories</h3>
    <div class="widget">
      <ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/categories/Android/">Android</a><span class="category-list-count">15</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/C/">C++</a><span class="category-list-count">4</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/Java/">Java</a><span class="category-list-count">6</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/NDK-Samples/">NDK Samples</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/Web/">Web</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/其它/">其它</a><span class="category-list-count">13</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/前端/">前端</a><span class="category-list-count">2</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/数据/">数据</a><span class="category-list-count">2</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/统计学/">统计学</a><span class="category-list-count">2</span></li></ul>
    </div>
  </div>

  
    
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tag Cloud</h3>
    <div class="widget tagcloud">
      <a href="/tags/02-00-00-00-00-00/" style="font-size: 10px;">02:00:00:00:00:00</a> <a href="/tags/301/" style="font-size: 10px;">301</a> <a href="/tags/302/" style="font-size: 10px;">302</a> <a href="/tags/APKParser/" style="font-size: 10px;">APKParser</a> <a href="/tags/AXMLPrinter2/" style="font-size: 10px;">AXMLPrinter2</a> <a href="/tags/Activity/" style="font-size: 10px;">Activity</a> <a href="/tags/Android-TV/" style="font-size: 10px;">Android TV</a> <a href="/tags/AndroidStudio/" style="font-size: 10px;">AndroidStudio</a> <a href="/tags/Arithmetic/" style="font-size: 10px;">Arithmetic</a> <a href="/tags/AutoService/" style="font-size: 10px;">AutoService</a> <a href="/tags/Bean/" style="font-size: 10px;">Bean</a> <a href="/tags/Butterknife/" style="font-size: 10px;">Butterknife</a> <a href="/tags/C/" style="font-size: 10px;">C++</a> <a href="/tags/Content-Type/" style="font-size: 10px;">Content-Type</a> <a href="/tags/DataBinding/" style="font-size: 10px;">DataBinding</a> <a href="/tags/DateFormat/" style="font-size: 10px;">DateFormat</a> <a href="/tags/Debugger/" style="font-size: 10px;">Debugger</a> <a href="/tags/DownloadManager/" style="font-size: 10px;">DownloadManager</a> <a href="/tags/Excel/" style="font-size: 10px;">Excel</a> <a href="/tags/FeignClient/" style="font-size: 10px;">FeignClient</a> <a href="/tags/FormEncoder/" style="font-size: 10px;">FormEncoder</a> <a href="/tags/Gradle/" style="font-size: 20px;">Gradle</a> <a href="/tags/Gson-serialization-deserialization-enum/" style="font-size: 10px;">Gson serialization/deserialization enum</a> <a href="/tags/Gson反序列化枚举/" style="font-size: 10px;">Gson反序列化枚举</a> <a href="/tags/Gson序列化枚举/" style="font-size: 10px;">Gson序列化枚举</a> <a href="/tags/How-compress/" style="font-size: 10px;">How compress</a> <a href="/tags/Http-Status-Code/" style="font-size: 10px;">Http Status Code</a> <a href="/tags/HttpClient/" style="font-size: 10px;">HttpClient</a> <a href="/tags/Huffman/" style="font-size: 10px;">Huffman</a> <a href="/tags/JNI/" style="font-size: 10px;">JNI</a> <a href="/tags/Java数据分析房价/" style="font-size: 10px;">Java数据分析房价</a> <a href="/tags/Jenkins/" style="font-size: 10px;">Jenkins</a> <a href="/tags/JitPack/" style="font-size: 10px;">JitPack</a> <a href="/tags/JsonDeserializer/" style="font-size: 10px;">JsonDeserializer</a> <a href="/tags/JsonSerializer/" style="font-size: 10px;">JsonSerializer</a> <a href="/tags/Mock/" style="font-size: 10px;">Mock</a> <a href="/tags/NODE-ENV/" style="font-size: 10px;">NODE_ENV</a> <a href="/tags/Native/" style="font-size: 10px;">Native</a> <a href="/tags/NetworkInterface/" style="font-size: 10px;">NetworkInterface</a> <a href="/tags/NullPointException/" style="font-size: 10px;">NullPointException</a> <a href="/tags/OSS/" style="font-size: 10px;">OSS</a> <a href="/tags/Qualifier/" style="font-size: 10px;">Qualifier</a> <a href="/tags/RestTemplate/" style="font-size: 10px;">RestTemplate</a> <a href="/tags/RestoreInstance/" style="font-size: 10px;">RestoreInstance</a> <a href="/tags/SDK/" style="font-size: 10px;">SDK</a> <a href="/tags/SDK更新给开发者/" style="font-size: 10px;">SDK更新给开发者</a> <a href="/tags/SimpleDateFormat/" style="font-size: 10px;">SimpleDateFormat</a> <a href="/tags/Spring/" style="font-size: 15px;">Spring</a> <a href="/tags/SpringBatch/" style="font-size: 10px;">SpringBatch</a> <a href="/tags/StepScope/" style="font-size: 10px;">StepScope</a> <a href="/tags/Time-Zone/" style="font-size: 10px;">Time Zone</a> <a href="/tags/TingPNG/" style="font-size: 10px;">TingPNG</a> <a href="/tags/TransformException/" style="font-size: 10px;">TransformException</a> <a href="/tags/WEBGL-debug-renderer-info/" style="font-size: 10px;">WEBGL_debug_renderer_info</a> <a href="/tags/WIFI/" style="font-size: 10px;">WIFI</a> <a href="/tags/WebGL/" style="font-size: 10px;">WebGL</a> <a href="/tags/WebView/" style="font-size: 15px;">WebView</a> <a href="/tags/WebView水印/" style="font-size: 10px;">WebView水印</a> <a href="/tags/WifiInfo/" style="font-size: 10px;">WifiInfo</a> <a href="/tags/YYYY/" style="font-size: 10px;">YYYY</a> <a href="/tags/object-Object/" style="font-size: 15px;">[object Object]</a> <a href="/tags/annotationProcessor/" style="font-size: 10px;">annotationProcessor</a> <a href="/tags/antd-init/" style="font-size: 10px;">antd-init</a> <a href="/tags/applicaton/" style="font-size: 10px;">applicaton</a> <a href="/tags/brew/" style="font-size: 10px;">brew</a> <a href="/tags/chrome/" style="font-size: 10px;">chrome</a> <a href="/tags/crash/" style="font-size: 10px;">crash</a> <a href="/tags/create-umi/" style="font-size: 10px;">create-umi</a> <a href="/tags/cross-env/" style="font-size: 10px;">cross-env</a> <a href="/tags/dependencies/" style="font-size: 10px;">dependencies</a> <a href="/tags/dummy0/" style="font-size: 10px;">dummy0</a> <a href="/tags/duplicate-entry/" style="font-size: 10px;">duplicate entry</a> <a href="/tags/experimental-webgl/" style="font-size: 10px;">experimental-webgl</a> <a href="/tags/feign-form/" style="font-size: 10px;">feign-form</a> <a href="/tags/fit/" style="font-size: 10px;">fit</a> <a href="/tags/flavor/" style="font-size: 10px;">flavor</a> <a href="/tags/github-api/" style="font-size: 10px;">github api</a> <a href="/tags/iOS/" style="font-size: 15px;">iOS</a> <a href="/tags/image-jpeg/" style="font-size: 10px;">image/jpeg</a> <a href="/tags/install/" style="font-size: 10px;">install</a> <a href="/tags/ipv4/" style="font-size: 10px;">ipv4</a> <a href="/tags/ipv6/" style="font-size: 10px;">ipv6</a> <a href="/tags/jpeg/" style="font-size: 10px;">jpeg</a> <a href="/tags/libjpeg/" style="font-size: 10px;">libjpeg</a> <a href="/tags/libjpeg-turbo/" style="font-size: 10px;">libjpeg-turbo</a> <a href="/tags/mac/" style="font-size: 10px;">mac</a> <a href="/tags/manifest/" style="font-size: 10px;">manifest</a> <a href="/tags/mockjs/" style="font-size: 10px;">mockjs</a> <a href="/tags/module/" style="font-size: 10px;">module</a> <a href="/tags/ndk-camera/" style="font-size: 10px;">ndk camera</a> <a href="/tags/onActivityForResult/" style="font-size: 10px;">onActivityForResult</a> <a href="/tags/onPageFinished/" style="font-size: 10px;">onPageFinished</a> <a href="/tags/registerTypeAdapter/" style="font-size: 10px;">registerTypeAdapter</a> <a href="/tags/scope/" style="font-size: 10px;">scope</a> <a href="/tags/spawn/" style="font-size: 10px;">spawn</a> <a href="/tags/storage/" style="font-size: 10px;">storage</a> <a href="/tags/transformClassesWithJarMerging/" style="font-size: 10px;">transformClassesWithJarMerging</a> <a href="/tags/v36/" style="font-size: 10px;">v36</a> <a href="/tags/versionCode/" style="font-size: 10px;">versionCode</a> <a href="/tags/vue/" style="font-size: 10px;">vue</a> <a href="/tags/watermark/" style="font-size: 10px;">watermark</a> <a href="/tags/wlan0/" style="font-size: 10px;">wlan0</a> <a href="/tags/yyyy/" style="font-size: 10px;">yyyy</a> <a href="/tags/下载图片/" style="font-size: 10px;">下载图片</a> <a href="/tags/中位数/" style="font-size: 10px;">中位数</a> <a href="/tags/中程数/" style="font-size: 10px;">中程数</a> <a href="/tags/主动push/" style="font-size: 10px;">主动push</a> <a href="/tags/人脸支付/" style="font-size: 15px;">人脸支付</a> <a href="/tags/人脸比对效率/" style="font-size: 10px;">人脸比对效率</a> <a href="/tags/众数/" style="font-size: 10px;">众数</a> <a href="/tags/兼容问题/" style="font-size: 10px;">兼容问题</a> <a href="/tags/同步支付/" style="font-size: 10px;">同步支付</a> <a href="/tags/命名空间/" style="font-size: 10px;">命名空间</a> <a href="/tags/图片链接/" style="font-size: 10px;">图片链接</a> <a href="/tags/均值/" style="font-size: 10px;">均值</a> <a href="/tags/多形参/" style="font-size: 10px;">多形参</a> <a href="/tags/头文件/" style="font-size: 10px;">头文件</a> <a href="/tags/如何主动PUSH/" style="font-size: 10px;">如何主动PUSH</a> <a href="/tags/异步支付/" style="font-size: 10px;">异步支付</a> <a href="/tags/引流/" style="font-size: 10px;">引流</a> <a href="/tags/支付/" style="font-size: 10px;">支付</a> <a href="/tags/数据决策/" style="font-size: 10px;">数据决策</a> <a href="/tags/数据分析/" style="font-size: 10px;">数据分析</a> <a href="/tags/春运交通情况/" style="font-size: 10px;">春运交通情况</a> <a href="/tags/智能硬件/" style="font-size: 10px;">智能硬件</a> <a href="/tags/权限/" style="font-size: 10px;">权限</a> <a href="/tags/极差/" style="font-size: 10px;">极差</a> <a href="/tags/构造函数/" style="font-size: 10px;">构造函数</a> <a href="/tags/模板/" style="font-size: 10px;">模板</a> <a href="/tags/水印/" style="font-size: 10px;">水印</a> <a href="/tags/浏览器显示图片/" style="font-size: 10px;">浏览器显示图片</a> <a href="/tags/用户体验/" style="font-size: 10px;">用户体验</a> <a href="/tags/网页水印/" style="font-size: 10px;">网页水印</a> <a href="/tags/脸部特征计算/" style="font-size: 10px;">脸部特征计算</a> <a href="/tags/蓝牙/" style="font-size: 10px;">蓝牙</a> <a href="/tags/蜻蜓/" style="font-size: 10px;">蜻蜓</a> <a href="/tags/重载默认参数函数/" style="font-size: 10px;">重载默认参数函数</a> <a href="/tags/阿里云显示图片/" style="font-size: 10px;">阿里云显示图片</a>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Archives</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2020/07/">July 2020</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2020/04/">April 2020</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2020/01/">January 2020</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/11/">November 2019</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/09/">September 2019</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/05/">May 2019</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/04/">April 2019</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/03/">March 2019</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/02/">February 2019</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/01/">January 2019</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/12/">December 2018</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/11/">November 2018</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/09/">September 2018</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/02/">February 2018</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/01/">January 2018</a><span class="archive-list-count">6</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/12/">December 2017</a><span class="archive-list-count">4</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/06/">June 2017</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/05/">May 2017</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/04/">April 2017</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/03/">March 2017</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/05/">May 2016</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/03/">March 2016</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/02/">February 2016</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/01/">January 2016</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/12/">December 2015</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/11/">November 2015</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/10/">October 2015</a><span class="archive-list-count">3</span></li></ul>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Recents</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/2020/07/17/browser-view-or-download-image-by-header/">浏览器打开图片链接时直接显示或下载到底怎么回事</a>
          </li>
        
          <li>
            <a href="/2020/04/19/watermark-by-android/">Android中添加背景水印，含WebView</a>
          </li>
        
          <li>
            <a href="/2020/04/08/use_mockjs_vue/">VUE中使用Mock模拟数据请求</a>
          </li>
        
          <li>
            <a href="/2020/04/04/annotation-proccor-by-gradle4-7/">annotationProcessor 引用后编译时不生效问题</a>
          </li>
        
          <li>
            <a href="/2020/01/08/enum-serializer-by-Gson/">Gson序列化、反序列化枚举</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2020 Tu<br>
      Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>
    </div>
    <nav id="mobile-nav">
  
    <a href="/" class="mobile-nav-link">Home</a>
  
    <a href="/archives" class="mobile-nav-link">Archives</a>
  
    <a href="/about" class="mobile-nav-link">About</a>
  
</nav>
    

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>


  <link rel="stylesheet" href="/fancybox/jquery.fancybox.css">
  <script src="/fancybox/jquery.fancybox.pack.js"></script>


<script src="/js/script.js"></script>

  </div>
</body>
</html>